<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use app\modules\Product\models\Product;
use kartik\select2\Select2;
use app\modules\Income\models\Income;

//获取自己所有的团队
$products_arr = Product::selfAll();

$products = [];
if($products_arr){
    foreach($products_arr as $p){
        $products[$p->id] = $p->code.'——'.$p->name;
    }
}

$income = Income::findOne($model->income_id);

?>

<style type="text/css">
    .list{margin: 10px;}
</style>
<div class="income-claim-form">

     <div class="row list">
        <div class="form-group">
            <label class="control-label col-sm-2" style="text-align: right;">收入编号</label>
            <div class="col-sm-7"><?=$income->code?></div>
        </div>
    </div>
    <div class="row list">
        <div class="form-group">
            <label class="control-label col-sm-2" style="text-align: right;">收入金额</label>
            <div class="col-sm-7"><?=$income->price?></div>
        </div>
     </div>   
     <div class="row list">
        <div class="form-group">
            <label class="control-label col-sm-2" style="text-align: right;">剩余认领金额</label>
            <div class="col-sm-7"><?=$income->notPrice?></div>
        </div>
     </div>  
     <?php $form = ActiveForm::begin([
             'options' => ['enctype' => 'multipart/form-data',],
             'layout' => 'horizontal',
             'fieldConfig' => [
                'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
                'horizontalCssClasses' => [
                    'label' => 'col-sm-2',
                    'wrapper' => 'col-sm-7',
                    'error' => '',
                ],
             ],
        ]); ?>

    <?= Html::activeHiddenInput($model, "income_id");?>

    <?= $form->field($model, 'product_id')->widget(Select2::classname(), [
            'language' => 'zh-cn',
            'options' => ['multiple'=>false,'placeholder' => '选择团队'],
            'data' => $products,
            'showToggleAll' => false,
            'pluginOptions' => [
                'allowClear' => true,
            ],
        ]); ?>

    <?= $form->field($model, 'currency')->inline(true)->radioList(Yii::$app->params['currency_type']) ?>

    <?= $form->field($model, 'price')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'remark')->textArea(['maxlength' => true]) ?>

    <div class="form-group text-center">
        <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
